package com.doge.util.aop;

import com.doge.exception.Param402Exception;
import com.doge.util.valid.ParamValidation;
import lombok.SneakyThrows;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindingResult;

/**
 * @program: doge
 * @description:
 * @author: Keyu Li
 * @create: 2021-12-03 16:52
 **/

@Aspect
@Component
public class TimeCountAspect {
    @Pointcut("@annotation(com.doge.util.anno.FuncTimeCount)")
    public void timePointcut(){}

    @SneakyThrows
    @Around("timePointcut()")
    public Object around(ProceedingJoinPoint joinPoint) {
        long start = System.currentTimeMillis();
        Object proceed = joinPoint.proceed();
        long end = System.currentTimeMillis();
        System.out.println("执行 "+ joinPoint.getSignature() +" 共耗时："+(end-start));
        return proceed;
    }
}
